package com.zhonghui.wms.controller;

import com.zhonghui.common.annotation.Log;
import com.zhonghui.common.core.controller.BaseController;
import com.zhonghui.common.core.page.TableDataInfo;
import com.zhonghui.common.enums.BusinessType;
import com.zhonghui.common.utils.poi.ExcelUtil;
import com.zhonghui.response.BaseResult;
import com.zhonghui.wms.domain.vo.WmsInventoryInformationVo;
import com.zhonghui.wms.service.IWmsInventoryInformationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 智能仓储WMS-盘点信息Controller
 *
 * @author zhonghui
 * @date 2022-05-27
 */
@Api(tags="智能仓储WMS-盘点信息")
@RestController
@RequestMapping("/wms/inventoryInformation")
public class WmsInventoryInformationController extends BaseController
{
    @Autowired
    private IWmsInventoryInformationService wmsInventoryInformationService;

    /**
     * 查询智能仓储WMS-盘点信息列表
     */
    @ApiOperation("查询智能仓储WMS-盘点信息列表")
    @GetMapping("/list")
    public TableDataInfo<List<WmsInventoryInformationVo>> list(WmsInventoryInformationVo wmsInventoryInformationVo)
    {
        startPage();
        List<WmsInventoryInformationVo> list = wmsInventoryInformationService.selectWmsInventoryInformationList(wmsInventoryInformationVo);
        return getDataTable(list);
    }

    /**
     * 查询智能仓储WMS-盘点信息列表不分页
     */
    @ApiOperation("查询智能仓储WMS-盘点信息列表不分页")
    @GetMapping("/noPageList")
    public BaseResult<List<WmsInventoryInformationVo>> pageList()
    {
        List<WmsInventoryInformationVo> list = wmsInventoryInformationService.selectWmsInventoryInformationNoPageList();
        return BaseResult.success(list);
    }

    /**
     * 导出智能仓储WMS-盘点信息列表
     */
    @Log(title = "智能仓储WMS-盘点信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsInventoryInformationVo wmsInventoryInformationVp)
    {
        List<WmsInventoryInformationVo> list = wmsInventoryInformationService.selectWmsInventoryInformationList(wmsInventoryInformationVp);
        ExcelUtil<WmsInventoryInformationVo> util = new ExcelUtil<WmsInventoryInformationVo>(WmsInventoryInformationVo.class);
        util.exportExcel(response, list, "智能仓储WMS-盘点信息数据");
    }

    /**
     * 获取智能仓储WMS-盘点信息详细信息
     */
    @ApiOperation("获取智能仓储WMS-盘点信息详细信息")
    @GetMapping(value = "/{id}")
    public BaseResult<WmsInventoryInformationVo> getInfo(@PathVariable("id") Long id)
    {
        return BaseResult.success(wmsInventoryInformationService.selectWmsInventoryInformationById(id));
    }

    /**
     * 新增智能仓储WMS-盘点信息
     */
    @ApiOperation("新增智能仓储WMS-盘点信息")
    @Log(title = "智能仓储WMS-盘点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public BaseResult<Integer> add(@RequestBody WmsInventoryInformationVo wmsInventoryInformationVo)
    {
        return BaseResult.success(wmsInventoryInformationService.insertWmsInventoryInformation(wmsInventoryInformationVo));
    }

    /**
     * 修改智能仓储WMS-盘点信息
     */
    @ApiOperation("修改智能仓储WMS-盘点信息")
    @Log(title = "智能仓储WMS-盘点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public BaseResult<Integer> edit(@RequestBody WmsInventoryInformationVo wmsInventoryInformation)
    {
        return BaseResult.success(wmsInventoryInformationService.updateWmsInventoryInformation(wmsInventoryInformation));
    }

    /**
     * 删除智能仓储WMS-盘点信息
     */
    @ApiOperation("删除智能仓储WMS-盘点信息")
    @Log(title = "智能仓储WMS-盘点信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public BaseResult<Integer> remove(@PathVariable Long[] ids)
    {
        return BaseResult.success(wmsInventoryInformationService.deleteWmsInventoryInformationByIds(ids));
    }
}
